package com.zb.select.controller;

import com.zb.entity.SelectVo;
import com.zb.result.Result;
import com.zb.select.service.GoodsSelectService;
import com.zb.service.*;
import com.zb.utils.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author WEN
 * @Date 2023/8/14 0014
 **/
@Api(tags = "商品下拉类接口")
@RestController
@RequestMapping("/goods/select")
public class GoodsSelectController {
    @Resource
    private GoodsSelectService goodsSelectService;
    @Resource
    private ZjBrandService brandService;
    @Resource
    private ZjGoodsTypeService goodsTypeService;
    @Resource
    private ZjGoodsUnitService goodsUnitService;
    @Resource
    private ZjGoodsSpecService specService;
    @Resource
    private ZjGoodsParamService paramService;
    @Resource
    private ZjSpareService spareService;
    @Resource
    private ZjSpareSpecInfoService specInfoService;
    @Resource
    private ZjProductService productService;
    @Resource
    private ZjProductSpecService productSpecService;

    @ApiOperation("分页获取品牌下拉列表")
    @PostMapping("/pageSelect")
    public Result pageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取品牌数据下拉列表成功").data(brandService.pageSelect(custAccId, selectVo));
    }

    @ApiOperation("分页获取商品分类下拉列表")
    @PostMapping("/typePageSelect")
    public Result typePageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("获取商品分类数据下拉列表成功").data(goodsTypeService.pageSelect(custAccId, selectVo));
    }

    @ApiOperation("分页获取单位下拉数据列表")
    @PostMapping("/unitPageSelect")
    public Result unitPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("分页获取单位下拉数据成功").data(goodsUnitService.pageSelect(custAccId, selectVo));
    }

    @ApiOperation("分页获取规格下拉数据列表")
    @PostMapping("/specPageSelect")
    public Result specPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("分页获取规格下拉数据成功").data(specService.pageSelect(custAccId, selectVo));
    }

    @ApiOperation("分页获取参数下拉数据列表")
    @PostMapping("/paramPageSelect")
    public Result paramPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("分页获取参数下拉数据成功").data(paramService.pageSelect(custAccId, selectVo));
    }

    @ApiOperation("分页获取备件下拉数据列表")
    @PostMapping("/sparePageSelect")
    public Result sparePageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("分页获取备件下拉数据成功").data(spareService.pageSelect(custAccId, selectVo));
    }

    @ApiOperation("分页获取备件规格下拉数据列表")
    @PostMapping("/spareSpecPageSelect/{spareId}")
    public Result spareSpecPageSelect(@PathVariable @ApiParam(value = "商品备件ID", required = true) Long spareId, @RequestBody SelectVo selectVo) {
        return Result.success("分页获取备件规格下拉数据成功").data(specInfoService.pageSelect(spareId, selectVo));
    }

    @ApiOperation("分页获取产品下拉数据列表")
    @PostMapping("/productPageSelect")
    public Result productPageSelect(HttpServletRequest request, @RequestBody SelectVo selectVo) {
        Long custAccId = TokenUtil.getcustAccIdByToken(request);
        return Result.success("分页获取产品下拉数据成功").data(productService.pageSelect(custAccId, selectVo));
    }

    @ApiOperation("分页获取产品规格下拉数据列表")
    @PostMapping("/productSpecPageSelect/{productId}")
    public Result productSpecPageSelect(@PathVariable @ApiParam(value = "商品产品ID", required = true) Long productId, @RequestBody SelectVo selectVo) {
        return Result.success("分页获取产品规格下拉数据成功").data(productSpecService.pageSelect(productId, selectVo));
    }


}
